package net.gyapp.markim.utils.libs;

import com.qiniu.android.common.FixedZone;
import com.qiniu.android.storage.Configuration;
import com.qiniu.android.storage.UploadManager;

/**
 * Auther:  winds
 * Email:   heardown@163.com
 * Date:    2018/7/19.
 * Desc:
 */

public class QiniuManager {
    private UploadManager uploadManager;

    public static class ManagerBuilder {
        private static QiniuManager builder = new QiniuManager();
    }


    private QiniuManager() {
        init();
    }

    void init() {
        Configuration config = new Configuration.Builder()
                .chunkSize(512 * 1024)        // 分片上传时，每片的大小。 默认256K
                .putThreshhold(1024 * 1024)   // 启用分片上传阀值。默认512K
                .connectTimeout(10)           // 链接超时。默认10秒
                .useHttps(true)               // 是否使用https上传域名
                .responseTimeout(60)          // 服务器响应超时。默认60秒
                .zone(FixedZone.zone0)        // 设置区域，指定不同区域的上传域名、备用域名、备用IP。
                .build();
        uploadManager = new UploadManager(config);
    }

    public static QiniuManager getInstance() {
        return ManagerBuilder.builder;
    }

    public UploadManager getUploadManager() {
        return uploadManager;
    }
}